
log using "Wang 2019 BJPS results",replace name(Wang2019BJPS)

********************************************************************************
**  Replication for
**
**  The Political Legacy of Violence during China's Cultural Revolution
**  British Journal of Political Science
**  Yuhua Wang (yuhuawang@fas.harvard.edu)
**
**  Original Do-File Created on 3/30/2016
**  This Version Created on 4/29/2019
**
**  Stata 14.2
********************************************************************************

clear
estimates clear 
set more off

cd "~/Documents/My Documents/Research/working papers/cultural revolution and trust/journal submission/bjps/4/replication/"


* install if you have not yet
* ssc install coefplot, interflex

********************************************************************************
*Tables and Figures in the Main Text of the Paper*
********************************************************************************

**********************
*Figure 1: Map in QGIS*
**********************

**********************
*Figure 2*
**********************

use "prefectualdata.dta",clear

local controls "sexratio_1964_pre urbanpopratio_1964_pre qingrebellion popdensity1964 lnpergdp shouzai extrap pmd longitude latitude resource colony suit_m distancetobeijing riverlength log_accountlength"
local province_fe "i.pro_n"

center CRdeath_pop_prefecture `controls', inplace standardize

xi: reg CRdeath_pop_prefecture `controls' `province_fe',cl(city_id)

coefplot, drop(_Ipro_n_* _cons) xline(0) xtitle(Standardized Coefficients) mfcolor(black) levels(99 95) ///
rename(sexratio_1964_pre="Male-to-Female Ratio" urbanpopratio_1964_pre="Urban Population Percentage" ///
qingrebellion="Frequency of Mass Rebellions" popdensity1964="Population Density" lnpergdp="Per Capita GDP" ///
shouzai="Natural Disasters" extrap="Excess Procurement Ratio" pmd="Party Membership Density" ///
longitude="Longitude" latitude="Latitude" resource="Natural Resource" colony="Colony" ///
suit_m="Suitability for Wetland Rice" distancetobeijing="Distance to Beijing" ///
riverlength="Length of Rivers" log_accountlength="Account Length")

graph export figure2.pdf, as(pdf) replace

clear

**********************
*Table 2*
**********************

use "chinasurvey.dta",clear

local individual_controls "male age agesquare han goodclass midclass"
local prefectural_controls "sexratio_1964_pre urbanpopratio_1964_pre qingrebellion popdensity1964 lnpergdp shouzai extrap pmd longitude latitude resource colony suit_m distancetobeijing riverlength"
local minimum_controls "log_accountlength i.prov"

xi:reg trustcentralhead CRdeath_pop_prefecture `minimum_controls' if local==1,cl(city_id)
estimates store table2_1
estadd ysumm

xi:reg trustcentralhead CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls' if local==1,cl(city_id)
estimates store table2_2
estadd ysumm

xi:reg lackingdemocracy CRdeath_pop_prefecture `minimum_controls'  if local==1,cl(city_id)
estimates store table2_3
estadd ysumm

xi:reg lackingdemocracy CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls'  if local==1,cl(city_id)
estimates store table2_4
estadd ysumm

xi:reg lackingfreeexpression CRdeath_pop_prefecture `minimum_controls' if local==1,cl(city_id)
estimates store table2_5
estadd ysumm

xi:reg lackingfreeexpression CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls' if local==1,cl(city_id)
estimates store table2_6
estadd ysumm

xi:reg everprotested CRdeath_pop_prefecture `minimum_controls' if local==1,cl(city_id)
estimates store table2_7
estadd ysumm

xi:reg everprotested CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls' if local==1,cl(city_id)
estimates store table2_8
estadd ysumm

esttab table2_1 table2_2 table2_3 table2_4 table2_5 table2_6 table2_7 table2_8 using table2.tex, ///
collabels(none)  cells(b(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01) replace ///
stats(N r2, fmt(0 3)  labels(`"N"' `"R2"')) drop(_Iprov*) ///
title(Table 2: OLS Estimates of the Effects of Cultural Revolution Violence on Political Attitudes and Behavior) 

*\ Standardized Coefficients, to be compared with Nunn and Wantchekon 2011*

preserve 

center trustcentralhead CRdeath_pop_prefecture, inplace standardize

local individual_controls "male age agesquare han goodclass midclass"
local prefectural_controls "sexratio_1964_pre urbanpopratio_1964_pre qingrebellion popdensity1964 lnpergdp shouzai extrap pmd longitude latitude resource colony suit_m distancetobeijing riverlength"
local minimum_controls "log_accountlength i.prov"

xi:reg trustcentralhead CRdeath_pop_prefecture `minimum_controls' if local==1,cl(city_id)
estimates store table2standard_1

xi:reg trustcentralhead CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls' if local==1,cl(city_id)
estimates store table2standard_2

esttab table2standard_1 table2standard_2 using table2standard.csv, ///
collabels(none)  cells(b(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01)  replace ///
stats(N r2, fmt(0 3)  labels(`"N"' `"R2"')) drop(_Iprov*) title(Standardized Coefficients) 

restore

**********************
*Table 3*
**********************

*\ Second Stage*

local individual_controls "male age agesquare han goodclass midclass"
local prefectural_controls "sexratio_1964_pre urbanpopratio_1964_pre qingrebellion popdensity1964 lnpergdp shouzai extrap pmd longitude latitude resource colony suit_m distancetobeijing riverlength"
local minimum_controls "log_accountlength i.prov"

xi:ivregress 2sls trustcentralhead (CRdeath_pop_prefecture=log_meandistancetosulphur) `individual_controls' `prefectural_controls' `minimum_controls'  if local==1, cl(city_id)
estimates store table3_1
estadd ysumm

xi:ivregress 2sls lackingdemocracy (CRdeath_pop_prefecture=log_meandistancetosulphur) `individual_controls' `prefectural_controls' `minimum_controls'  if local==1, cl(city_id)
estimates store table3_2
estadd ysumm

xi:ivregress 2sls lackingfreeexpression (CRdeath_pop_prefecture=log_meandistancetosulphur) `individual_controls' `prefectural_controls' `minimum_controls'  if local==1, cl(city_id)
estimates store table3_3
estadd ysumm

xi:ivregress 2sls everprotested (CRdeath_pop_prefecture=log_meandistancetosulphur) `individual_controls' `prefectural_controls' `minimum_controls'  if local==1, cl(city_id)
estimates store table3_4
estadd ysumm

esttab table3_1 table3_2 table3_3 table3_4 using table3.tex, ///
collabels(none)  cells(b(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01)  replace ///
stats(N r2, fmt(0 3)  labels(`"N"' `"R2"')) drop(_Iprov*) ///
title(Table 3: IV Estimates of the Effects of Cultural Revolution Violence on Political Attitudes and Behavior) 

*\ Hausman Tests*

local individual_controls "male age agesquare han goodclass midclass"
local prefectural_controls "sexratio_1964_pre urbanpopratio_1964_pre qingrebellion popdensity1964 lnpergdp shouzai extrap pmd longitude latitude resource colony suit_m distancetobeijing riverlength"
local minimum_controls "log_accountlength i.prov"

quietly xi:ivreg trustcentralhead (CRdeath_pop_prefecture=log_meandistancetosulphur) `individual_controls' `prefectural_controls' `minimum_controls'  if local==1
ivendog 

quietly xi:ivreg lackingdemocracy (CRdeath_pop_prefecture=log_meandistancetosulphur) `individual_controls' `prefectural_controls' `minimum_controls'  if local==1
ivendog 

quietly xi:ivreg lackingfreeexpression (CRdeath_pop_prefecture=log_meandistancetosulphur) `individual_controls' `prefectural_controls' `minimum_controls'  if local==1
ivendog 

quietly xi:ivreg everprotested (CRdeath_pop_prefecture=log_meandistancetosulphur) `individual_controls' `prefectural_controls' `minimum_controls'  if local==1
ivendog 

*\ First Stage (with F-stats)*
local individual_controls "male age agesquare han goodclass midclass"
local prefectural_controls "sexratio_1964_pre urbanpopratio_1964_pre qingrebellion popdensity1964 lnpergdp shouzai extrap pmd longitude latitude resource colony suit_m distancetobeijing riverlength"
local minimum_controls "log_accountlength i.prov"

xi: reg CRdeath_pop_prefecture log_meandistancetosulphur `individual_controls' `prefectural_controls' `minimum_controls' if trustcentralhead~=. & local==1, cl(city_id)
*F-stat*
test log_meandistancetosulphur=0
estimates store table3firststage_1

xi: reg CRdeath_pop_prefecture log_meandistancetosulphur `individual_controls' `prefectural_controls' `minimum_controls' if lackingdemocracy~=.& local==1, cl(city_id)
*F-stat*
test log_meandistancetosulphur=0
estimates store table3firststage_2

xi: reg CRdeath_pop_prefecture log_meandistancetosulphur `individual_controls' `prefectural_controls' `minimum_controls' if lackingfreeexpression~=.& local==1, cl(city_id)
*F-stat*
test log_meandistancetosulphur=0
estimates store table3firststage_3

xi: reg CRdeath_pop_prefecture log_meandistancetosulphur `individual_controls' `prefectural_controls' `minimum_controls' if everprotested~=.& local==1, cl(city_id)
*F-stat*
test log_meandistancetosulphur=0
estimates store table3firststage_4

esttab table3firststage_1 table3firststage_2 table3firststage_3 table3firststage_4 using table3firststage.tex, ///
collabels(none)  cells(b(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01)  replace ///
stats(N r2, fmt(0 3)  labels(`"N"' `"R2"')) drop(_Iprov*) title(Table 3 First Stage) 

**********************
*Figure 3*
**********************

interflex trustcentralhead CRdeath_pop_prefecture birthyear log_accountlength _Iprov_21-_Iprov_65, cl(city_id) ylabel(Trust in Central Leaders) dlabel(Cultural Revolution Violence) xlabel(Year of Birth) sav(figure3.gph)

**********************
*Figure 4*
**********************

interflex trustcentralhead CRdeath_pop_prefecture familydiscuss log_accountlength _Iprov_21-_Iprov_65 if birthyear>=1977, cl(city_id) ylabel(Trust in Central Leaders) dlabel(Cultural Revolution Violence) xlabel(Discussing Politics with Family) sav(figure4.gph)





********************************************************************************
*Tables and Figures in the Online Appendix*
********************************************************************************

use "chinasurvey.dta",clear

**************************
*Table 1.1*
**************************

tab trustcentralhead if local==1
tab lackingdemocracy if local==1
tab lackingfreeexpression if local==1
tab protest if local==1

**************************
*Table 2.1*
**************************

global y "trustgeneral trustfamily trustrelative trustcentralhead lackingdemocracy lackingfreeexpression everprotested"
global x "CRdeath_pop_prefecture CRdeath_pop_county CRdeath_log splag1_CRdeath_pop_prefecture_p "
global individual_controls "male birthyear age agesquare han goodclass midclass familydiscuss sentdowngeneration"
global minimum_controls "log_accountlength"
global prefectural_controls "sexratio_1964_pre urbanpopratio_1964_pre qingrebellion popdensity1964 lnpergdp shouzai extrap pmd longitude latitude resource colony suit_m distancetobeijing riverlength"

estpost sum  $y $individual_controls $x  $minimum_controls $prefectural_controls if local==1

esttab, cells("count mean sd min max") noobs

**************************
*Table 2.2*
**************************

local individual_controls "male age agesquare han goodclass midclass"
local prefectural_controls "sexratio_1964_pre urbanpopratio_1964_pre qingrebellion popdensity1964 lnpergdp shouzai extrap pmd longitude latitude resource colony suit_m distancetobeijing riverlength"
local minimum_controls "log_accountlength i.prov"

xi:reg trustgeneral CRdeath_pop_prefecture `minimum_controls' if local==1,cl(city_id)
estimates store table2_2_1

xi:reg trustgeneral CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls' if local==1,cl(city_id)
estimates store table2_2_2

xi:reg trustfamily CRdeath_pop_prefecture `minimum_controls' if local==1,cl(city_id)
estimates store table2_2_3

xi:reg trustfamily CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls' if local==1,cl(city_id)
estimates store table2_2_4

xi:reg trustrelative CRdeath_pop_prefecture `minimum_controls' if local==1,cl(city_id)
estimates store table2_2_5

xi:reg trustrelative CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls' if local==1,cl(city_id)
estimates store table2_2_6

esttab table2_2_1 table2_2_2 table2_2_3 table2_2_4 table2_2_5 table2_2_6 using table2_2.csv, ///
collabels(none)  cells(b(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01)  replace ///
stats(N r2, fmt(0 3)  labels(`"N"' `"R2"')) drop(_Iprov*) title(Table 2.2: OLS Estimates of the Effects of Cultural Revolution Violence on Interpersonal Trust) 

clear

**************************
*Table 2.3*
**************************

use "prefectualdata.dta",clear

local controls "sexratio_1964_pre urbanpopratio_1964_pre qingrebellion popdensity1964 lnpergdp shouzai extrap pmd longitude latitude resource colony suit_m distancetobeijing riverlength log_accountlength"
local province_fe "i.pro_n"

preserve

center CRdeath_pop_prefecture `controls', inplace standardize

xi: reg CRdeath_pop_prefecture `controls' `province_fe',cl(city_id)
estimates store table2_3

esttab table2_3 using table2_3.csv, ///
collabels(none)  cells(b(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01)  replace ///
stats(N r2, fmt(0 3)  labels(`"N"' `"R2"')) drop(_Ipro_n_*) title(Table 2.3: Determinants of Cultural Revolution Violence Across Chinese Prefectures) 

restore

clear

**************************
*Table 3.1*
**************************

use "chinasurvey.dta",clear

local individual_controls "male age agesquare han goodclass midclass"
local prefectural_controls "sexratio_1964_pre urbanpopratio_1964_pre qingrebellion popdensity1964 lnpergdp shouzai extrap pmd longitude latitude resource colony suit_m distancetobeijing riverlength"
local minimum_controls "log_accountlength i.prov"

xi:reg trustcentralhead CRdeath_pop_prefecture `minimum_controls' if local==1,cl(city_id)
estimates store table3_1_1
estadd ysumm

xi:reg trustcentralhead CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls' if local==1,cl(city_id)
estimates store table3_1_2
estadd ysumm

xi:reg lackingdemocracy CRdeath_pop_prefecture `minimum_controls'  if local==1,cl(city_id)
estimates store table3_1_3
estadd ysumm

xi:reg lackingdemocracy CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls'  if local==1,cl(city_id)
estimates store table3_1_4
estadd ysumm

xi:reg lackingfreeexpression CRdeath_pop_prefecture `minimum_controls' if local==1,cl(city_id)
estimates store table3_1_5
estadd ysumm

xi:reg lackingfreeexpression CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls' if local==1,cl(city_id)
estimates store table3_1_6
estadd ysumm

xi:reg everprotested CRdeath_pop_prefecture `minimum_controls' if local==1,cl(city_id)
estimates store table3_1_7
estadd ysumm

xi:reg everprotested CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls' if local==1,cl(city_id)
estimates store table3_1_8
estadd ysumm

esttab table3_1_1 table3_1_2 table3_1_3 table3_1_4 table3_1_5 table3_1_6 table3_1_7 table3_1_8 using table3_1.csv, ///
collabels(none)  cells(b(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01)  replace ///
stats(N r2, fmt(0 3)  labels(`"N"' `"R2"')) drop(_Iprov*) ///
title(Table 3.1: OLS Estimates of the Effects of Cultural Revolution Violence on Political Attitudes and Behavior) 

****************
*Table 4.1*
****************

local individual_controls "male age agesquare han goodclass midclass"
local prefectural_controls "sexratio_1964_pre urbanpopratio_1964_pre qingrebellion popdensity1964 lnpergdp shouzai extrap pmd longitude latitude resource colony suit_m distancetobeijing riverlength"
local minimum_controls "log_accountlength i.prov"

*Non-sent-down*

xi:reg trustcentralhead CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls' if birthyear<1977 & sentdowngeneration==0 & local==1,cl(city_id)
estimates store table4_1_1

xi:reg lackingdemocracy CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls' if birthyear<1977 & sentdowngeneration==0 & local==1,cl(city_id)
estimates store table4_1_3

xi:reg lackingfreeexpression CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls' if birthyear<1977 & sentdowngeneration==0 & local==1,cl(city_id)
estimates store table4_1_5

xi:reg everprotested CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls' if birthyear<1977 & sentdowngeneration==0 & local==1,cl(city_id)
estimates store table4_1_7

*Sent-down*

xi:reg trustcentralhead CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls' if birthyear<1977 & sentdowngeneration==1 & local==1,cl(city_id)
estimates store table4_1_2

xi:reg lackingdemocracy CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls' if birthyear<1977 & sentdowngeneration==1 & local==1,cl(city_id)
estimates store table4_1_4

xi:reg lackingfreeexpression CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls' if birthyear<1977 & sentdowngeneration==1 & local==1,cl(city_id)
estimates store table4_1_6

xi:reg everprotested CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls' if birthyear<1977 & sentdowngeneration==1 & local==1,cl(city_id)
estimates store table4_1_8

esttab table4_1_1 table4_1_2 table4_1_3 table4_1_4 table4_1_5 table4_1_6 table4_1_7 table4_1_8 using table4_1.csv, ///
collabels(none)  cells(b(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01)  replace ///
stats(N r2, fmt(0 3)  labels(`"N"' `"R2"')) drop(_Iprov*)  title(Table 4.1: OLS Estimates of the Effects of Cultural Revolution Violence on Political Attitudes and Behavior by Sent-Down Experience) 


****************
*Table 4.2*
****************

local individual_controls "male age agesquare han goodclass midclass"
local prefectural_controls "sexratio_1964_pre urbanpopratio_1964_pre qingrebellion popdensity1964 lnpergdp shouzai extrap pmd longitude latitude resource colony suit_m distancetobeijing riverlength"
local minimum_controls "log_accountlength i.prov"

xi:reg trustcentralhead CRdeath_pop_county `individual_controls' `prefectural_controls' `minimum_controls' if local==1,cl(countyid)
estimates store table4_2_1

xi:reg lackingdemocracy CRdeath_pop_county `individual_controls' `prefectural_controls' `minimum_controls' if local==1,cl(countyid)
estimates store table4_2_2

xi:reg lackingfreeexpression CRdeath_pop_county `individual_controls' `prefectural_controls' `minimum_controls' if local==1,cl(countyid)
estimates store table4_2_3

xi:reg everprotested CRdeath_pop_county `individual_controls' `prefectural_controls' `minimum_controls' if local==1,cl(countyid)
estimates store table4_2_4

esttab table4_2_1 table4_2_2 table4_2_3 table4_2_4 using table4_2.csv, ///
collabels(none)  cells(b(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01)  replace ///
stats(N r2, fmt(0 3)  labels(`"N"' `"R2"')) drop(_Iprov*)  title(Table 4.2 OLS Estimates of the Effects of Cultural Revolution Violence on Political Attitudes and Behavior Using County-Level Data) 


****************
*Table 4.3*
****************

preserve

*sort city_id
*by city_id: gen respondent_id=_n

xtset city_id respondent_id

local individual_controls "male age agesquare han goodclass midclass"
local prefectural_controls "sexratio_1964_pre urbanpopratio_1964_pre qingrebellion popdensity1964 lnpergdp shouzai extrap pmd longitude latitude resource colony suit_m distancetobeijing riverlength"
local minimum_controls "log_accountlength i.prov"

xi:xtmixed trustcentralhead CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls' if local==1||city_id:, mle difficult
estimates store table4_3_1

xi:xtmixed lackingdemocracy CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls' if local==1||city_id:, mle difficult
estimates store table4_3_2

xi:xtmixed lackingfreeexpression CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls' if local==1||city_id:, mle difficult
estimates store table4_3_3

xi:xtmixed everprotested CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls' if local==1||city_id:, mle difficult
estimates store table4_3_4

esttab table4_3_1 table4_3_2 table4_3_3 table4_3_4 using table4_3.csv, ///
collabels(none)  cells(b(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01)  replace ///
stats(N r2, fmt(0 3)  labels(`"N"' `"R2"')) drop(_Iprov*) title(Table 4.3: Maximum Likelihood Estimates of the Effects of Cultural Revolution Violence on Political Attitudes and Behavior using Multilevel Modeling) 

restore

clear

****************
*Table 4.4*
****************

*Use a separate dataset to avoid messing up the original data*

use "chinasurveyforMI.dta",clear

* This dataset has been mi set and prepared using the following commands:

*mi set mlong

*mi register imputed trustcentralhead lackingdemocracy lackingfreeexpression everprotested

*mi misstable summarize trustcentralhead lackingdemocracy lackingfreeexpression everprotested, all

*mi impute regress trustcentralhead male age agesquare han goodclass midclass,add(20) rseed(1114) force
*mi impute regress lackingdemocracy male age agesquare han goodclass midclass,add(20) rseed(1115) force
*mi impute regress lackingfreeexpression male age agesquare han goodclass midclass,add(20) rseed(1116) force
*mi impute regress everprotested male age agesquare han goodclass midclass,add(20) rseed(1116) force

*drop if trustcentralhead==. | lackingfreeexpression==. | lackingdemocracy==. | everprotested==.|  male==. | age==. | agesquare==. | han==. | goodclass==. | midclass==. | log_accountlength==. | sexratio_1964_pre==. | urbanpopratio_1964_pre==. | qingrebellion==. | popdensity1964==. | lnpergdp==. | shouzai==. | extrap==. | pmd==. | longitude==. | latitude==. | resource==. | colony==. | suit_m==. | distancetobeijing==. | riverlength==. | CRdeath_pop_prefecture==.

local individual_controls "male age agesquare han goodclass midclass"
local prefectural_controls "sexratio_1964_pre urbanpopratio_1964_pre qingrebellion popdensity1964 lnpergdp shouzai extrap pmd longitude latitude resource colony suit_m distancetobeijing riverlength"
local minimum_controls "log_accountlength i.prov"

xi: eststo: mi estimate, post:reg trustcentralhead CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls' if local==1,cl(city_id)
estimates store table4_4_1

xi: eststo:mi estimate, post:reg lackingdemocracy CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls' if local==1,cl(city_id)
estimates store table4_4_2

xi: eststo:mi estimate, post:reg lackingfreeexpression CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls' if local==1,cl(city_id)
estimates store table4_4_3

xi: eststo:mi estimate, post:reg everprotested CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls' if local==1,cl(city_id)
estimates store table4_4_4

esttab table4_4_1 table4_4_2 table4_4_3 table4_4_4 using table4_4.csv, ///
collabels(none) c(b_mi(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01)  replace ///
stats(N r2, fmt(0 3)  labels(`"N"' `"R2"')) drop(_Iprov*) title(Table 4.4: OLS Estimates of the Effects of Cultural Revolution Violence on Political Attitudes and Behavior Using Imputed Data) 

clear

****************
*Table 4.5*
****************

use "chinasurvey.dta",clear
 
*log*
*gen CRdeath_log=log(CRdeath_pop_prefecture+1)
*label var CRdeath_log "log transformed CRdeath_pop_prefecture+1"

local individual_controls "male age agesquare han goodclass midclass"
local prefectural_controls "sexratio_1964_pre urbanpopratio_1964_pre qingrebellion popdensity1964 lnpergdp shouzai extrap pmd longitude latitude resource colony suit_m distancetobeijing riverlength"
local minimum_controls "log_accountlength i.prov"

xi:reg trustcentralhead CRdeath_log `individual_controls' `prefectural_controls' `minimum_controls' if local==1,cl(city_id)
estimates store table4_5_1

xi:reg lackingdemocracy CRdeath_log `individual_controls' `prefectural_controls' `minimum_controls' if local==1,cl(city_id)
estimates store table4_5_2

xi:reg lackingfreeexpression CRdeath_log `individual_controls' `prefectural_controls' `minimum_controls' if local==1,cl(city_id)
estimates store table4_5_3

xi:reg everprotested CRdeath_log `individual_controls' `prefectural_controls' `minimum_controls' if local==1,cl(city_id)
estimates store table4_5_4

esttab table4_5_1 table4_5_2 table4_5_3 table4_5_4 using table4_5.csv, ///
collabels(none)  cells(b(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01)  replace ///
stats(N r2, fmt(0 3)  labels(`"N"' `"R2"')) drop(_Iprov*) title(Table 4.5: Using Log Transformed Independent Variable) 


****************
*Table 4.6*
****************

svyset psu [pweight=wt_respo]

local individual_controls "male age agesquare han goodclass midclass"
local prefectural_controls "sexratio_1964_pre urbanpopratio_1964_pre qingrebellion popdensity1964 lnpergdp shouzai extrap pmd longitude latitude resource colony suit_m distancetobeijing riverlength"
local minimum_controls "log_accountlength i.prov"

xi:svy: reg trustcentralhead CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls' if local==1
estimates store table4_6_1

xi:svy: reg lackingdemocracy CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls' if local==1
estimates store table4_6_2

xi:svy: reg lackingfreeexpression CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls' if local==1
estimates store table4_6_3

xi:svy: reg everprotested CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls' if local==1
estimates store table4_6_4

esttab table4_6_1 table4_6_2 table4_6_3 table4_6_4 using table4_6.csv, ///
collabels(none)  cells(b(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01)  replace ///
stats(N r2, fmt(0 3)  labels(`"N"' `"R2"')) drop(_Iprov*)  title(Table 4.6: Considering Survey Design Effects (OLS Estimates)) 

****************
*Table 4.7*
****************

*The following commands are used to generate spatial lag from the raw data

*use "/Users/ywang/Documents/My Documents/Research/working papers/cultural revolution and trust/data/raw/spatial lag/CRdata_prefecture_spatial.dta"
*spgen CRdeath_pop_prefecture, lat(latitude) lon(longitude) swm(pow 1) dist(.) dunit(km) approx 
*clear
*use "chinasurvey.dta"
*merge m:1 city_id using  "/Users/ywang/Documents/My Documents/Research/working papers/cultural revolution and trust/data/raw/spatial lag/CRdata_prefecture_spatial.dta"
*drop if _merge==2
*drop _merge
*save "chinasurvey.dta", replace

local individual_controls "male age agesquare han goodclass midclass"
local prefectural_controls "sexratio_1964_pre urbanpopratio_1964_pre qingrebellion popdensity1964 lnpergdp shouzai extrap pmd longitude latitude resource colony suit_m distancetobeijing riverlength"
local minimum_controls "log_accountlength i.prov"
local spatial_lag "splag1_CRdeath_pop_prefecture_p"

xi:reg trustcentralhead CRdeath_pop_prefecture `spatial_lag' `individual_controls' `prefectural_controls' `minimum_controls' if local==1,cl(city_id)
estimates store table4_7_1

xi:reg lackingdemocracy CRdeath_pop_prefecture `spatial_lag' `individual_controls' `prefectural_controls' `minimum_controls' if local==1,cl(city_id)
estimates store table4_7_2

xi:reg lackingfreeexpression CRdeath_pop_prefecture `spatial_lag' `individual_controls' `prefectural_controls' `minimum_controls' if local==1,cl(city_id)
estimates store table4_7_3

xi:reg everprotested CRdeath_pop_prefecture `spatial_lag' `individual_controls' `prefectural_controls' `minimum_controls' if local==1,cl(city_id)
estimates store table4_7_4

esttab table4_7_1 table4_7_2 table4_7_3 table4_7_4 using table4_7.csv, ///
collabels(none)  cells(b(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01)  replace ///
stats(N r2, fmt(0 3)  labels(`"N"' `"R2"')) drop(_Iprov*) title(Table 4.7: OLS Estimates of the Effects of Cultural Revolution Violence on Political Attitudes and Behavior with a Spatial Lag) 

****************
*Figures 4.1-4.4*
****************

*egen prefectureid=group(city_id) 

local individual_controls "male age agesquare han goodclass midclass"
local prefectural_controls "sexratio_1964_pre urbanpopratio_1964_pre qingrebellion popdensity1964 lnpergdp shouzai extrap pmd longitude latitude resource colony suit_m distancetobeijing riverlength"
local minimum_controls "log_accountlength i.prov"

forvalues i=1(1)59 { 
	quietly xi:reg trustcentralhead CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls' if local==1 & prefectureid~=`i',cl(city_id)
	gen beta1_`i'=_b[CRdeath_pop_prefecture]
	gen se1_`i'=_se[CRdeath_pop_prefecture]
    
}  

	
	forvalues i=1(1)59 { 
	quietly xi:reg lackingdemocracy CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls' if local==1 & prefectureid~=`i',cl(city_id)
	gen beta2_`i'=_b[CRdeath_pop_prefecture]
	gen se2_`i'=_se[CRdeath_pop_prefecture]
    
}  

forvalues i=1(1)59 { 
	quietly xi:reg lackingfreeexpression CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls' if local==1 & prefectureid~=`i',cl(city_id)
	gen beta3_`i'=_b[CRdeath_pop_prefecture]
	gen se3_`i'=_se[CRdeath_pop_prefecture]
    
}  

forvalues i=1(1)59 { 
	quietly xi:reg everprotested CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls' if local==1 & prefectureid~=`i',cl(city_id)
	gen beta4_`i'=_b[CRdeath_pop_prefecture]
	gen se4_`i'=_se[CRdeath_pop_prefecture]
    
}  	
	sum beta1_1-se1_59 
	drop beta1_1-se1_59
	
	sum beta2_1-se2_59 
	drop beta2_1-se2_59
	
	sum beta3_1-se3_59 
	drop beta3_1-se3_59
	
	sum beta4_1-se4_59 
	drop beta4_1-se4_59

clear
	
*Paste the following data into Stata*
excludedcity	beta1	se1	beta2	se2	beta3	se3	beta4	se4
1	-0.2082204	0.042814	1.206442	0.1834728	1.224455	0.1873738	-0.0141588	0.0027051
2	-0.3125139	0.0582292	1.233575	0.2453954	0.9082953	0.2434242	-0.0119318	0.0036447
3	-0.3089663	0.0245002	1.119954	0.1499288	0.8759212	0.1293861	-0.0125666	0.0020313
4	-0.1897637	0.0630856	1.374012	0.2353564	1.134915	0.22885	-0.0137577	0.0030909
5	-0.182528	0.0625854	1.387216	0.2347175	1.148788	0.2271983	-0.013559	0.0030989
6	-0.2593761	0.0374065	1.130773	0.148052	1.04742	0.1705877	-0.0130632	0.002055
7	-0.2473519	0.032046	1.1308	0.1511791	1.067476	0.1678974	-0.0131106	0.0020395
8	-0.2593761	0.0374065	1.130773	0.148052	1.04742	0.1705877	-0.0130632	0.002055
9	-0.2468477	0.0321158	1.130555	0.1506243	1.056975	0.1690383	-0.0131119	0.0020412
10	-0.2596127	0.0374704	1.13105	0.1485004	1.032188	0.1704265	-0.0130852	0.0020553
11	-0.2411699	0.0416092	1.044704	0.1316263	0.9695311	0.1605185	-0.0104837	0.00175
12	-0.2423627	0.0415533	1.043553	0.1306438	0.9521199	0.1590077	-0.0112534	0.0019666
13	-0.2593761	0.0374065	1.130773	0.148052	1.04742	0.1705877	-0.0130632	0.002055
14	-0.2593761	0.0374065	1.130773	0.148052	1.04742	0.1705877	-0.0130632	0.002055
15	-0.2593761	0.0374065	1.130773	0.148052	1.04742	0.1705877	-0.0130632	0.002055
16	-0.2066079	0.0341212	1.303085	0.213843	1.1716	0.1793139	-0.0148354	0.0025558
17	-0.206587	0.0343355	1.299965	0.2149859	1.167283	0.1798561	-0.0148394	0.0025565
18	-0.2618912	0.0385	1.019556	0.1030102	1.00646	0.1574501	-0.0120347	0.0017183
19	-0.2629365	0.0386972	1.018965	0.1033336	1.000937	0.1590662	-0.012114	0.0017575
20	-0.2892358	0.0356486	1.234028	0.1569483	1.060156	0.1839309	-0.0150072	0.0020989
21	-0.2891061	0.0353793	1.240735	0.1570895	1.06693	0.1813888	-0.0150007	0.0020965
22	-0.2806165	0.0416583	1.103424	0.1633056	1.040704	0.1762008	-0.013531	0.0021596
23	-0.2833288	0.041404	1.109002	0.1641736	1.048028	0.1775526	-0.0135335	0.0021598
24	-0.2593761	0.0374065	1.130773	0.148052	1.04742	0.1705877	-0.0130632	0.002055
25	-0.2593761	0.0374065	1.130773	0.148052	1.04742	0.1705877	-0.0130632	0.002055
26	-0.2593761	0.0374065	1.130773	0.148052	1.04742	0.1705877	-0.0130632	0.002055
27	-0.2638079	0.035019	1.165486	0.1469862	1.068792	0.1697176	-0.0146194	0.0020766
28	-0.260893	0.0348547	1.171249	0.1474297	1.071322	0.1712868	-0.0146334	0.002084
29	-0.2402469	0.0431801	1.191245	0.1893389	1.115226	0.1874418	-0.0139181	0.0024381
30	-0.273698	0.0525184	0.8266371	0.1310663	0.561843	0.0923261	-0.0087836	0.0020187
31	-0.2543177	0.0751029	0.7530426	0.1748631	0.3662	0.1948906	-0.0074752	0.0027557
32	-0.2593761	0.0374065	1.130773	0.148052	1.04742	0.1705877	-0.0130632	0.002055
33	-0.2614631	0.0396623	1.108741	0.1561886	1.074148	0.1781319	-0.0122187	0.0019739
34	-0.2573538	0.0393853	1.078378	0.1493539	1.0148	0.175882	-0.0127914	0.0019724
35	-0.2642454	0.0364018	1.170075	0.1556236	1.082145	0.1770933	-0.0129092	0.0020049
36	-0.2580102	0.037601	1.139423	0.1532799	1.055356	0.1719615	-0.0130929	0.002066
37	-0.2755828	0.0351531	1.175201	0.1470822	1.08756	0.1668806	-0.0132547	0.0020723
38	-0.2591634	0.0377371	1.030508	0.1381977	1.067347	0.1718647	-0.0131691	0.0020144
39	-0.2537215	0.0388219	1.093083	0.1324029	1.055741	0.1736929	-0.0131027	0.0020684
40	-0.2462155	0.0605175	0.9086249	0.1736873	1.151555	0.2167076	-0.0134444	0.0023606
41	-0.2593761	0.0374065	1.130773	0.148052	1.04742	0.1705877	-0.0130632	0.002055
42	-0.2466101	0.0600314	0.8922952	0.1733426	1.126847	0.2058334	-0.01345	0.0023653
43	-0.2593761	0.0374065	1.130773	0.148052	1.04742	0.1705877	-0.0130632	0.002055
44	-0.2598618	0.0364896	1.134101	0.1487098	1.051384	0.1560715	-0.0131205	0.0018362
45	-0.2529652	0.0375773	1.145011	0.1475991	1.074242	0.1649022	-0.0131112	0.0020967
46	-0.2451053	0.0352499	1.155152	0.1323579	1.116077	0.1065937	-0.013798	0.0016205
47	-0.2593761	0.0374065	1.130773	0.148052	1.04742	0.1705877	-0.0130632	0.002055
48	-0.2584435	0.0373113	1.130076	0.1510615	1.052626	0.1726464	-0.0130887	0.0020791
49	-0.2650682	0.0376947	1.16507	0.1527137	1.124346	0.1705647	-0.0133587	0.0020287
50	-0.2958103	0.0398216	1.214832	0.2039352	0.9705528	0.1715469	-0.0127246	0.0020924
51	-0.2635093	0.0397962	1.224991	0.1884955	0.9486488	0.1401181	-0.0127943	0.0021024
52	-0.260473	0.0379201	1.131782	0.1470492	1.047146	0.1713115	-0.0129714	0.002236
53	-0.2597732	0.0377675	1.128235	0.1461161	1.046356	0.1724922	-0.0129782	0.0022383
54	-0.252949	0.0397919	1.131994	0.149429	1.040627	0.1705124	-0.0135396	0.0020288
55	-0.2520149	0.0389979	1.130742	0.1489718	1.041098	0.1707702	-0.0135287	0.0020287
56	-0.2593761	0.0374065	1.130773	0.148052	1.04742	0.1705877	-0.0130632	0.002055
57	-0.2593761	0.0374065	1.130773	0.148052	1.04742	0.1705877	-0.0130632	0.002055
58	-0.2593761	0.0374065	1.130773	0.148052	1.04742	0.1705877	-0.0130632	0.002055
59	-0.2593761	0.0374065	1.130773	0.148052	1.04742	0.1705877	-0.0130632	0.002055

gen upper95ci1=beta1+1.96*se1
gen upper95ci2=beta2+1.96*se2
gen upper95ci3=beta3+1.96*se3
gen upper95ci4=beta4+1.96*se4

gen lower95ci1=beta1-1.96*se1
gen lower95ci2=beta2-1.96*se2
gen lower95ci3=beta3-1.96*se3
gen lower95ci4=beta4-1.96*se4

save "dropcityestimates.dta", replace

use "dropcityestimates.dta", clear

twoway (scatter beta1 excludedcity, mcolor(black) msize(vsmall) name(trust,replace)) ///
  (rcap lower95ci1 upper95ci1 excludedcity, vertical lcolor(black) lwidth(vthin) msize(vtiny)), ///
  legend(on) graphregion(fcolor(white) lcolor(white)) xlab(0(10)60) ylab(, nogrid) yline(0, lcolor(black) lpattern(dash)) ///
  ytitle("Effects of Cultural Revolution Violence") xtitle("Excluded City") title("Trust in Central Leaders") ///
  legend(on)  legend(pos(6) ring(1) col(2) lab(1 "Beta") lab(2 "Lower/Upper 95% CI"))
  graph export "figure4_1.pdf", replace

  twoway (scatter beta2 excludedcity, mcolor(black) msize(vsmall) name(democracy,replace)) ///
  (rcap lower95ci2 upper95ci2 excludedcity, vertical lcolor(black) lwidth(vthin) msize(vtiny)), ///
  legend(on) graphregion(fcolor(white) lcolor(white)) xlab(0(10)60) ylab(0(0.5)2, nogrid) yline(0, lcolor(black) lpattern(dash)) ///
  ytitle("Effects of Cultural Revolution Violence") xtitle("Excluded City") title("Democracy") ///
  legend(on)  legend(pos(6) ring(1) col(2) lab(1 "Beta") lab(2 "Lower/Upper 95% CI"))
  graph export "figure4_2.pdf", replace
  
  twoway (scatter beta3 excludedcity, mcolor(black) msize(vsmall) name(expression,replace)) ///
  (rcap lower95ci3 upper95ci3 excludedcity, vertical lcolor(black) lwidth(vthin) msize(vtiny)), ///
  legend(on) graphregion(fcolor(white) lcolor(white)) xlab(0(10)60) ylab(0(0.5)2, nogrid) yline(0, lcolor(black) lpattern(dash)) ///
  ytitle("Effects of Cultural Revolution Violence") xtitle("Excluded City") title("Freedom of Expression") ///
  legend(on)  legend(pos(6) ring(1) col(2) lab(1 "Beta") lab(2 "Lower/Upper 95% CI"))
  graph export "figure4_3.pdf", replace
  
  twoway (scatter beta4 excludedcity, mcolor(black) msize(vsmall) name(protest,replace)) ///
  (rcap lower95ci4 upper95ci4 excludedcity, vertical lcolor(black) lwidth(vthin) msize(vtiny)), ///
  legend(on) graphregion(fcolor(white) lcolor(white)) xlab(0(10)60) ylab(-0.02(0.005)0, nogrid) yline(0, lcolor(black) lpattern(dash)) ///
  ytitle("Effects of Cultural Revolution Violence") xtitle("Excluded City") title("Protest") ///
  legend(on)  legend(pos(6) ring(1) col(2) lab(1 "Beta") lab(2 "Lower/Upper 95% CI"))
  graph export "figure4_4.pdf", replace
  
clear


****************
*Figure 5.1: Map in QGIS*
****************

****************
*Figure 5.2: Scatterplot in R*
****************

*Paste the following R code into R

*library(foreign) 

*data <- read.dta("/Users/ywang/Documents/My Documents/Research/working papers/cultural revolution and trust/graphs/sulfur mine and death/chinasurvey.dta")

*attach(data)


*library(ggplot2) 

*require(ggplot2)


*ggplot(data, aes(x=log_meandistancetosulphur, y=CRdeath_pop_prefecture),) +
*    geom_point(shape=1) +   
*    geom_smooth(method=lm) +
*   labs(x="Average Distance to Sulfur Mines (log)", y = "Number of Deaths/1,000") +
*    annotate("text", x = 6, y = 4, label = "r=0.20,p<0.01")

	
****************
*Table 5.1*
****************

cd "~/Documents/My Documents/Research/working papers/cultural revolution and trust/journal submission/bjps/4/replication/"

use "prefectualdataforIV.dta",clear

xi: reg pc_gongan log_meandistancetosulphur i.provincecode,cl(provincecode)
estimates store table5_1_1

xi: reg gongan_density log_meandistancetosulphur i.provincecode,cl(provincecode)
estimates store table5_1_2

esttab table5_1_1 table5_1_2 using table5_1.csv, ///
collabels(none)  cells(b(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01)  replace ///
stats(N r2, fmt(0 3)  labels(`"N"' `"R2"')) drop(_Iprovincec_*) title(Table 5.1: OLS Estimates of the Effects of Average Distance to Sulfur Mines on Contemporary Repression) 

****************
*Table 5.2*
****************

xi: reg pc_gdp log_meandistancetosulphur i.provincecode,cl(provincecode)
estimates store table5_2_1

xi: reg perceivedcorruption log_meandistancetosulphur i.provincecode,cl(provincecode)
estimates store table5_2_2

xi: reg expcorruption log_meandistancetosulphur i.provincecode,cl(provincecode)
estimates store table5_2_3

xi: reg bureaucraticinteractiondays log_meandistancetosulphur i.provincecode,cl(provincecode)
estimates store table5_2_4

xi: reg expectationofinformalpaymentsfor log_meandistancetosulphur i.provincecode,cl(provincecode)
estimates store table5_2_5

xi: reg city_confidenceincourts log_meandistancetosulphur i.provincecode,cl(provincecode)
estimates store table5_2_6

xi: reg GOVSIZE log_meandistancetosulphur i.provincecode,cl(provincecode)
estimates store table5_2_7

xi: reg averageschooling2000 log_meandistancetosulphur i.provincecode,cl(provincecode)
estimates store table5_2_8

esttab table5_2_1 table5_2_2 table5_2_3 table5_2_4 table5_2_5 table5_2_6 table5_2_7 table5_2_8 using table5_2.csv, ///
collabels(none)  cells(b(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01)  replace ///
stats(N r2, fmt(0 3)  labels(`"N"' `"R2"')) drop(_Iprovincec_*) title(Table 5.2: OLS Estimates of the Effects of Average Distance to Sulfur Mines on Contemporary Quality of Government) 

clear


**********************
*Table 5.3*
**********************

use "chinasurvey.dta", clear

local individual_controls "male age agesquare han goodclass midclass"
local prefectural_controls "sexratio_1964_pre urbanpopratio_1964_pre qingrebellion popdensity1964 lnpergdp shouzai extrap pmd longitude latitude resource colony suit_m distancetobeijing riverlength"
local minimum_controls "log_accountlength i.prov"

xi:ivregress 2sls trustcentralhead (CRdeath_pop_prefecture=log_meandistancetosulphur) `individual_controls' `prefectural_controls' `minimum_controls'  if local==1, cl(city_id)
estimates store table5_3_1
estadd ysumm

xi:ivregress 2sls lackingdemocracy (CRdeath_pop_prefecture=log_meandistancetosulphur) `individual_controls' `prefectural_controls' `minimum_controls'  if local==1, cl(city_id)
estimates store table5_3_2
estadd ysumm

xi:ivregress 2sls lackingfreeexpression (CRdeath_pop_prefecture=log_meandistancetosulphur) `individual_controls' `prefectural_controls' `minimum_controls'  if local==1, cl(city_id)
estimates store table5_3_3
estadd ysumm

xi:ivregress 2sls everprotested (CRdeath_pop_prefecture=log_meandistancetosulphur) `individual_controls' `prefectural_controls' `minimum_controls'  if local==1, cl(city_id)
estimates store table5_3_4
estadd ysumm

esttab table5_3_1 table5_3_2 table5_3_3 table5_3_4 using table5_3.csv, ///
collabels(none)  cells(b(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01)  replace ///
stats(N r2, fmt(0 3)  labels(`"N"' `"R2"')) drop(_Iprov*) ///
title(Table 5.3: IV Estimates of the Effects of Cultural Revolution Violence: Second Stage Results) 

*\ Hausman Tests*

local individual_controls "male age agesquare han goodclass midclass"
local prefectural_controls "sexratio_1964_pre urbanpopratio_1964_pre qingrebellion popdensity1964 lnpergdp shouzai extrap pmd longitude latitude resource colony suit_m distancetobeijing riverlength"
local minimum_controls "log_accountlength i.prov"

quietly xi:ivreg trustcentralhead (CRdeath_pop_prefecture=log_meandistancetosulphur) `individual_controls' `prefectural_controls' `minimum_controls'  if local==1
ivendog 

quietly xi:ivreg lackingdemocracy (CRdeath_pop_prefecture=log_meandistancetosulphur) `individual_controls' `prefectural_controls' `minimum_controls'  if local==1
ivendog 

quietly xi:ivreg lackingfreeexpression (CRdeath_pop_prefecture=log_meandistancetosulphur) `individual_controls' `prefectural_controls' `minimum_controls'  if local==1
ivendog 

quietly xi:ivreg everprotested (CRdeath_pop_prefecture=log_meandistancetosulphur) `individual_controls' `prefectural_controls' `minimum_controls'  if local==1
ivendog 

**********************
*Table 5.4*
**********************

local individual_controls "male age agesquare han goodclass midclass"
local prefectural_controls "sexratio_1964_pre urbanpopratio_1964_pre qingrebellion popdensity1964 lnpergdp shouzai extrap pmd longitude latitude resource colony suit_m distancetobeijing riverlength"
local minimum_controls "log_accountlength i.prov"

xi: reg CRdeath_pop_prefecture log_meandistancetosulphur `individual_controls' `prefectural_controls' `minimum_controls' if trustcentralhead~=. & local==1, cl(city_id)
*F-stat*
test log_meandistancetosulphur=0
estimates store table5_4_1

xi: reg CRdeath_pop_prefecture log_meandistancetosulphur `individual_controls' `prefectural_controls' `minimum_controls' if lackingdemocracy~=.& local==1, cl(city_id)
*F-stat*
test log_meandistancetosulphur=0
estimates store table5_4_2

xi: reg CRdeath_pop_prefecture log_meandistancetosulphur `individual_controls' `prefectural_controls' `minimum_controls' if lackingfreeexpression~=.& local==1, cl(city_id)
*F-stat*
test log_meandistancetosulphur=0
estimates store table5_4_3

xi: reg CRdeath_pop_prefecture log_meandistancetosulphur `individual_controls' `prefectural_controls' `minimum_controls' if everprotested~=.& local==1, cl(city_id)
*F-stat*
test log_meandistancetosulphur=0
estimates store table5_4_4

esttab table5_4_1 table5_4_2 table5_4_3 table5_4_4 using table5_4.csv, ///
collabels(none)  cells(b(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01)  replace ///
stats(N r2, fmt(0 3)  labels(`"N"' `"R2"')) drop(_Iprov*) title(Table 5.4: IV Estimates of the Effects of Cultural Revolution Violence: First Stage Results) 


**********************
*Table 5.5*
**********************

local individual_controls "male age agesquare han goodclass midclass"
local prefectural_controls "sexratio_1964_pre urbanpopratio_1964_pre qingrebellion popdensity1964 lnpergdp shouzai extrap pmd longitude latitude resource colony suit_m distancetobeijing riverlength"
local minimum_controls "log_accountlength i.prov"

xi:ivregress 2sls trustcentralhead (CRdeath_pop_prefecture=anysulphur) `individual_controls' `prefectural_controls' `minimum_controls'  if local==1, cl(city_id)
estimates store table5_5_1
estadd ysumm

xi:ivregress 2sls lackingdemocracy (CRdeath_pop_prefecture=anysulphur) `individual_controls' `prefectural_controls' `minimum_controls'  if local==1, cl(city_id)
estimates store table5_5_2
estadd ysumm

xi:ivregress 2sls lackingfreeexpression (CRdeath_pop_prefecture=anysulphur) `individual_controls' `prefectural_controls' `minimum_controls'  if local==1, cl(city_id)
estimates store table5_5_3
estadd ysumm

xi:ivregress 2sls everprotested (CRdeath_pop_prefecture=anysulphur) `individual_controls' `prefectural_controls' `minimum_controls'  if local==1, cl(city_id)
estimates store table5_5_4
estadd ysumm

esttab table5_5_1 table5_5_2 table5_5_3 table5_5_4 using table5_5.csv, ///
collabels(none)  cells(b(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01)  replace ///
stats(N r2, fmt(0 3)  labels(`"N"' `"R2"')) drop(_Iprov*) title(Table 5.5: IV Estimates of the Effects of Cultural Revolution Violence: Second Stage Results using Presence of Sulfur Mine) 

*Hauman test*

local individual_controls "male age agesquare han goodclass midclass"
local prefectural_controls "sexratio_1964_pre urbanpopratio_1964_pre qingrebellion popdensity1964 lnpergdp shouzai extrap pmd longitude latitude resource colony suit_m distancetobeijing riverlength"
local minimum_controls "log_accountlength i.prov"

quietly xi:ivreg trustcentralhead (CRdeath_pop_prefecture=anysulphur) `individual_controls' `prefectural_controls' `minimum_controls'  if local==1
ivendog 

quietly xi:ivreg lackingdemocracy (CRdeath_pop_prefecture=anysulphur) `individual_controls' `prefectural_controls' `minimum_controls'  if local==1
ivendog 

quietly xi:ivreg lackingfreeexpression (CRdeath_pop_prefecture=anysulphur) `individual_controls' `prefectural_controls' `minimum_controls'  if local==1
ivendog 

quietly xi:ivreg everprotested (CRdeath_pop_prefecture=anysulphur) `individual_controls' `prefectural_controls' `minimum_controls'  if local==1
ivendog 

**********************
*Table 5.6*
**********************

local individual_controls "male age agesquare han goodclass midclass"
local prefectural_controls "sexratio_1964_pre urbanpopratio_1964_pre qingrebellion popdensity1964 lnpergdp shouzai extrap pmd longitude latitude resource colony suit_m distancetobeijing riverlength"
local minimum_controls "log_accountlength i.prov"

xi: reg CRdeath_pop_prefecture anysulphur `individual_controls' `prefectural_controls' `minimum_controls' if trustcentralhead~=. & local==1, cl(city_id)
test anysulphur=0
estimates store table5_6_1
estadd ysumm

xi: reg CRdeath_pop_prefecture anysulphur `individual_controls' `prefectural_controls' `minimum_controls' if lackingdemocracy~=.& local==1, cl(city_id)
test anysulphur=0
estimates store table5_6_2
estadd ysumm

xi: reg CRdeath_pop_prefecture anysulphur `individual_controls' `prefectural_controls' `minimum_controls' if lackingfreeexpression~=.& local==1, cl(city_id)
test anysulphur=0
estimates store table5_6_3
estadd ysumm

xi: reg CRdeath_pop_prefecture anysulphur `individual_controls' `prefectural_controls' `minimum_controls' if everprotested~=.& local==1, cl(city_id)
test anysulphur=0
estimates store table5_6_4
estadd ysumm

esttab table5_6_1 table5_6_2 table5_6_3 table5_6_4 using table5_6.csv, ///
collabels(none)  cells(b(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01)  replace ///
stats(N r2, fmt(0 3)  labels(`"N"' `"R2"')) drop(_Iprov*) title(Table 5.6: IV Estimates of the Effects of Cultural Revolution Violence: First Stage Results using Presence of Sulfur Mine) 


****************
*Table 6.1*
* and *
*Figures 6.1-6.3*
****************

interflex trustcentralhead CRdeath_pop_prefecture birthyear log_accountlength _Iprov_21-_Iprov_65, cl(city_id) ylabel(Trust in Central Leaders) dlabel(Cultural Revolution Violence) xlabel(Year of Birth)

return list
mat list r(estBin)

interflex lackingdemocracy CRdeath_pop_prefecture birthyear log_accountlength _Iprov_21-_Iprov_65, cl(city_id) ylabel(Democracy) dlabel(Cultural Revolution Violence) xlabel(Year of Birth) sav(figure6_1.gph)

return list
mat list r(estBin)

interflex lackingfreeexpression CRdeath_pop_prefecture birthyear log_accountlength _Iprov_21-_Iprov_65, cl(city_id) ylabel(Freedom of Expression) dlabel(Cultural Revolution Violence) xlabel(Year of Birth) sav(figure6_2.gph)

return list
mat list r(estBin)

interflex everprotested CRdeath_pop_prefecture birthyear log_accountlength _Iprov_21-_Iprov_65, cl(city_id) ylabel(Protest) dlabel(Cultural Revolution Violence) xlabel(Year of Birth) sav(figure6_3.gph)

return list
mat list r(estBin)



****************
*Table 6.2*
* and *
*Figures 6.4-6.6*
****************

interflex trustcentralhead CRdeath_pop_prefecture familydiscuss log_accountlength _Iprov_21-_Iprov_65 if birthyear>=1977, cl(city_id) ylabel(Trust in Central Leaders) dlabel(Cultural Revolution Violence) xlabel(Discussing Politics with Family)

return list
mat list r(estBin)

interflex lackingdemocracy CRdeath_pop_prefecture familydiscuss log_accountlength _Iprov_21-_Iprov_65 if birthyear>=1977, cl(city_id) ylabel(Democracy) dlabel(Cultural Revolution Violence) xlabel(Discussing Politics with Family) sav(figure6_4.gph)

return list
mat list r(estBin)

interflex lackingfreeexpression CRdeath_pop_prefecture familydiscuss log_accountlength _Iprov_21-_Iprov_65 if birthyear>=1977, cl(city_id) ylabel(Freedom of Expression) dlabel(Cultural Revolution Violence) xlabel(Discussing Politics with Family) sav(figure6_5.gph)

return list
mat list r(estBin)

interflex everprotested CRdeath_pop_prefecture familydiscuss log_accountlength _Iprov_21-_Iprov_65 if birthyear>=1977, cl(city_id) ylabel(Protest) dlabel(Cultural Revolution Violence) xlabel(Discussing Politics with Family) sav(figure6_6.gph)

return list
mat list r(estBin)

****************
*Table 6.3*
****************

local individual_controls "male age agesquare han goodclass midclass"
local prefectural_controls "sexratio_1964_pre urbanpopratio_1964_pre qingrebellion popdensity1964 lnpergdp shouzai extrap pmd longitude latitude resource colony suit_m distancetobeijing riverlength"
local minimum_controls "log_accountlength i.prov"

xi: reg familydiscuss CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls' if birthyear>=1977 & local==1, cl(city_id)
estimates store table6_3

esttab table6_3 using table6_3.csv, ///
collabels(none)  cells(b(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01)  replace ///
stats(N r2, fmt(0 3)  labels(`"N"' `"R2"'))  drop(_Iprov*) title(Table 6.3: OLS Estimates of the Determinants of Discussing Politics with Family) 

****************
*Table 6.4*
****************

local individual_controls "male age agesquare han goodclass midclass"
local prefectural_controls "sexratio_1964_pre urbanpopratio_1964_pre qingrebellion popdensity1964 lnpergdp shouzai extrap pmd longitude latitude resource colony suit_m distancetobeijing riverlength"
local minimum_controls "log_accountlength i.prov"

xi:reg trustcentralhead CRdeath_pop_prefecture `minimum_controls' if local==0,cl(city_id)
estimates store table6_4_1
estadd ysumm

xi:reg trustcentralhead CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls' if local==0,cl(city_id)
estimates store table6_4_2
estadd ysumm

xi:reg lackingdemocracy CRdeath_pop_prefecture `minimum_controls'  if local==0,cl(city_id)
estimates store table6_4_3
estadd ysumm

xi:reg lackingdemocracy CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls'  if local==0,cl(city_id)
estimates store table6_4_4
estadd ysumm

xi:reg lackingfreeexpression CRdeath_pop_prefecture `minimum_controls' if local==0,cl(city_id)
estimates store table6_4_5
estadd ysumm

xi:reg lackingfreeexpression CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls' if local==0,cl(city_id)
estimates store table6_4_6
estadd ysumm

xi:reg everprotested CRdeath_pop_prefecture `minimum_controls' if local==0,cl(city_id)
estimates store table6_4_7
estadd ysumm

xi:reg everprotested CRdeath_pop_prefecture `individual_controls' `prefectural_controls' `minimum_controls' if local==0,cl(city_id)
estimates store table6_4_8
estadd ysumm

esttab table6_4_1 table6_4_2 table6_4_3 table6_4_4 table6_4_5 table6_4_6 table6_4_7 table6_4_8 using table6_4.csv, ///
collabels(none)  cells(b(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01)  replace ///
stats(N r2, fmt(0 3)  labels(`"N"' `"R2"'))  drop(_Iprov*) title(Table 6.4: OLS Estimates of the Effects of Cultural Revolution Violence on New Residents) 

clear

********************************************************************************
*THE END*
********************************************************************************

log close Wang2019BJPS

exit



